<?php
declare (strict_types = 1);

namespace app\middleware;

use think\facade\Session;

class Guest
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response|\think\response\Redirect
     */
    public function handle($request, \Closure $next)
    {
        if(isLogin()){
            Session::flash('warning','您已登录~');//你已经登录了就不能在跳转到注册登录页了
            return redirect((string) url('home'));
        }
        return $next($request);
    }
}
